package com.lx.mobileplayer.mvp.view.fragment

import android.view.View
import com.itheima.player.model.bean.MvAreaBean
import com.lx.mobileplayer.R
import com.lx.mobileplayer.mvp.persenter.MvPresenter
import com.lx.mobileplayer.mvp.view.Iview.IMvView
import com.lx.mobileplayer.mvp.view.adapter.MvChildFragmentAdapter
import com.lx.mobileplayer.utils.ToastUtil
import kotlinx.android.synthetic.main.fragment_mv.*

/**
 * 类说明：首页
 * Created by liuxiong on 2019/4/24.
 */
class MvFragment :BaseFragment(),IMvView{

    private val mPresenter by lazy{
        MvPresenter(this)
    }

    var mAdapter:MvChildFragmentAdapter?=null

    override fun initContentView(): View {
        return View.inflate(getMContext(), R.layout.fragment_mv,null)
    }

    override fun initView() {
        super.initView()


    }

    override fun initData() {
        super.initData()
        mPresenter.requestData()
    }

    override fun onFailed(code: Int, message: String) {
        ToastUtil.show("加载区域数据失败")
    }

    override fun onSuccess(data: ArrayList<MvAreaBean>) {
//        ToastUtil.show("加载区域数据成功")

        tabLayout.setupWithViewPager(viewPager)
        mAdapter=MvChildFragmentAdapter(data,childFragmentManager)
        viewPager.adapter= mAdapter
    }

}